# 将二叉树展开为链表

# 遍历顺序，根 -> 左子树 -> 右子树

class TreeNode:

    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

    
class Solution:
    head = None
    def flatten(self, root) -> None:
        if not root:
            return
        
        self.flatten(root.right)
        self.flatten(root.left)
        root.left = None
        root.right = self.head
        self.head = root






